package com.eve.eplus.common.task;

import java.io.File;

import android.content.Context;

import com.eve.eplus.common.app.Configuration;
import com.eve.eplus.common.tools.LogTools;



public class AbstractFileCache {

	private String dirString;
	
	public AbstractFileCache(Context context) {
		
		dirString = getCacheDir();
		boolean ret = FileHelper.createDirectory(dirString);
		LogTools.info("FileHelper.createDirectory:" + dirString + ", ret = " + ret);
	}
	
	public File getFile(String url) {
		File f = new File(getSavePath(url));
		return f;
	}
	

    public String getSavePath(String url) {
        String filename = String.valueOf(url.hashCode());
        return getCacheDir() + filename;
    }


    public String getCacheDir() {
        
        return Configuration.CACHE_PATH;
    }

	public void clear() {
		FileHelper.deleteDirectory(dirString);
	}

}
